11/27/2022
We can simulate data from a normal distribution as follows:
set.seed(144) x1 <- rnorm(n= 1000, 0, 1) x2 <- rnorm(n=1000, 3, 4) data <- as.data.frame(cbind(x1, x2))
You could also sample form a multivariate normal distributions, but we won’t do that here.
require(MASS) Sigma <- matrix(c(7,5,5,9),2,2) data_mv <- as.data.frame(mvrnorm(n = 1000, rep(0, 2), Sigma))
require(DT, warn.conflicts = F) datatable(data, options = list(pageLength = 5))
require(reshape, warn.conflicts = F) data <- melt(data) datatable(data, options = list(pageLength = 5))
require(plotly)
p <- ggplot(data, aes(x = value, fill = variable)) +
geom_density(alpha=.25) +
ggtitle("Normal densities")
ggplotly(p)
The distribution of \(X_1\): \[X_1 \sim \mathcal{N}(0, 1).\]
The distribution of \(X_2\): \[X_2 \sim \mathcal{N}(3, 4).\]
So two beautiful normal distributions.
This doesn’t relate to the normal density stuff, but we can take the inverse of functions:
\[ \begin{align} g_i(\mu_{ij}) &= \nu_{i} + \lambda_i \eta_j \\ \mu_{ij} &= g_i^{-1}(\nu_{i} + \lambda_i \eta_j). \end{align} \]
These relate to the Generalized Linear Factor Analysis Framework, originally proposed by